package hik;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;



public class RedisClient {

    public static JedisPool jedisPool;//非切片连接池
  static  { 
        initialPool(); 
    } 
 
    /**
     * 初始化非切片池
     */
    private static void initialPool() 
    { 
        // 池基本配置 
        JedisPoolConfig config = new JedisPoolConfig(); 
        config.setMaxActive(20); 
        config.setMaxIdle(5); 
        config.setMaxWait(1000l); 
        config.setTestOnBorrow(false); 
        jedisPool = new JedisPool(config, "192.168.100.9", 6379, 3000, "Nari_jysp3.0", 8);
    }
    
    
    public static void close(Jedis jedis) {     
        jedisPool.returnResource(jedis);
    } 
    
    public static void main(String[] args) {
    	Jedis jedis = RedisClient.jedisPool.getResource();
		jedis.set("name", Math.random()+"");
		RedisClient.close(jedis);
	}

}